
import socket
import time

s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
localaddr = ("192.168.1.113",10006)
s.bind(localaddr)
str1 = "tom"
recv_data = ""
while True:
    #s.sendto(str(str1).encode(), ('192.168.1.116', 10006))
    recv_data = s.recvfrom(1024)
    recv_msg = recv_data[0]
    send_addr = recv_data[1]
    print(":%s :%s" %(str(send_addr),recv_msg.decode("gbk")))

    print(str1)
    time.sleep(1)
udp_socket.close()